import pymysql

mysql = pymysql.connect(host='localhost',
                        user='root',
                        password='123456',
                        database='jianzhimao')
cursor = mysql.cursor()


def CreateTable(sql):
    try:
        cursor.execute(sql)
        mysql.commit()
    except:
        return 500


def InsertData(sql):
    try:
        cursor.execute(sql)
        mysql.commit()
    except:
        return 400


def AlterData(sql):
    try:
        cursor.execute(sql)
        mysql.commit()
    except:
        return 300


def UpdataData(sql):
    try:
        cursor.execute(sql)
        mysql.commit()
    except:
        return 200


def ShowData(sql):
    try:
        cursor.execute(sql)
        mysql.commit()
        return cursor.fetchall()
    except:
        return 100


def DelData(sql):
    try:
        cursor.execute(sql)
        mysql.commit()
    except:
        return 0


